import java.util.Scanner;

public class Parkla {
	public static void main(String[] args) {
		GameField field = new GameField();
		field.addCars(5);
		field.printField();
		
		Scanner scan = new Scanner(System.in);
		
		while(!field.isGameFinished()) {
			String[] tokens = scan.nextLine().split(" ");
			
			if(tokens.length != 2) {
				System.out.println("Input must contain two elements.");
			}
			else if(tokens[0].length() != 1) {
				System.out.println("First element must be a single character.");
			}
			else if(!field.makeMove(tokens[0].charAt(0), tokens[1])) {
				System.out.println(field.getErrorString());
			}
			else {
				System.out.println("Move successful.");
				field.printField();
			}
		}
		
		System.out.println("Game finished.");
	}
}
